<%@ include file="/common/taglibs.jsp" %>

<head>
    <title><fmt:message key="configList.title"/></title>
    <meta name="menu" content="AdminMenu"/>
</head>

<div>
    <h2><fmt:message key="configList.header"/></h2>

	<s:form name="configs" action="saveConfig" method="post" validate="false">

	 
    <s:submit type="button" cssClass="btn" method="cancel" key="button.cancel" theme="simple">
            <i class="icon-remove"></i>
            <fmt:message key="button.cancel"/>
    </s:submit>
    <s:submit type="button" cssClass="btn btn-primary" method="saveAll" key="button.save" theme="simple">
            <i class="icon-ok icon-white"></i>
            <fmt:message key="button.save"/>
    </s:submit>
        
 	<c:forEach items="${ configs }" var="c">
 	    
 	    <h4>
 	    	<span style="cursor:pointer;" onclick="trigger('${ c.key }')">
 	        	<span id="expand_${ c.key }" style="display:''"><img  src="${ ctx }/images/toggle-expand.png"></img></span>
 	        	<span id="collapse_${ c.key }" style="display:none"><img src="${ ctx }/images/toggle-collapse.png"></img></span>
 	        </span> 
 	        <fmt:message key="config.menu.${ c.key }"/>
 	    </h4>
 	    
 	    <div id="${ c.key }" style="display:none;">
	 		
	 		<display:table name="${ c.value }" cellspacing="0" cellpadding="0" requestURI="" 
		                   defaultsort="1" id="configs" pagesize="1000"  class="table table-condensed table-striped table-hover" export="false">
		        <display:setProperty name="paging.banner.no_items_found" value="" />
		        <display:setProperty name="paging.banner.one_item_found" value="" />
		        <display:setProperty name="paging.banner.all_items_found" value="" />
		        
	    		<display:column style="width: 40%" titleKey="Config.constant">
					<strong>${configs.constant}</strong><br>
					<small><span style="color:red;"><fmt:message key="config.constant.types"/>: <fmt:message key="config.${configs.constant}.types"/></span></small><br>
					<small><fmt:message key="config.constant.description"/>: <fmt:message key="config.${configs.constant}"/></small> 
				</display:column>
				<display:column style="width: 60%" titleKey="Config.value">
					<textarea style="width:95%; height: 100%;" cols='100' rows='1'  name="valoresCargados['${configs.constant}']" >${configs.valueEncoded}</textarea>
				</display:column>
			</display:table>	
 	    
 	    </div>
 	    
 	</c:forEach>
	<s:submit type="button" cssClass="btn" method="cancel" key="button.cancel" theme="simple">
            <i class="icon-remove"></i>
            <fmt:message key="button.cancel"/>
    </s:submit>
    <s:submit type="button" cssClass="btn btn-primary" method="saveAll" key="button.save" theme="simple">
            <i class="icon-ok icon-white"></i>
            <fmt:message key="button.save"/>
    </s:submit>
	</s:form>
</div>

<script type="text/javascript">
	function trigger(id) {
		
		if ($('#expand_'+id).is(":visible")) {			
			$('#'+id).show("slow");
			$('#expand_'+id).hide();
			$('#collapse_'+id).show();
		} else {
			$('#'+id).hide("hide");
			$('#expand_'+id).show();
			$('#collapse_'+id).hide();
		}
	}
</script>
